package com.zrrd.yt.user.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zrrd.yt.model.user.UserAddress;
import com.zrrd.yt.user.service.UserAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author HongyueYang
 */
@RestController
@RequestMapping("/api/user")
public class UserAddressController {
    @Autowired
    private UserAddressService userAddressService;

    //获取用户地址
    @GetMapping("/inner/findUserAddressByUserId/{userId}")
    public List<UserAddress> findUserAddressByUserId(@PathVariable("userId") Long userId){
        QueryWrapper<UserAddress> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id",userId);
        List<UserAddress> addressList = userAddressService.list(wrapper);
        return addressList;
    }
}
